package struts.form;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FullForm {
	public FullForm(){}
	public static ActionForm full(String formpath,HttpServletRequest request){
		ActionForm form = null;
		try{
			Class  clazz = Class.forName(formpath);
			form = (ActionForm) clazz.newInstance();
			Field [] fa = clazz.getDeclaredFields();
			for(Field f:fa){
				f.setAccessible(true);
				f.set(form, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
		}catch(Exception e){
			e.printStackTrace();
			System.out.println("警告:form装载error");
		}
		return form;
	}
}
